package org.springblade.modules.admin.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.dto.ChatGroupDTO;
import org.springblade.modules.admin.service.IChatGroupService;
import org.springframework.web.bind.annotation.*;

/**
 * Robot chat group controller
 * @author Sharry
 * @since 2023/5/15
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/robot")
@Api(tags = "消息推送机器人Controller",value = "/robot")
public class ChatGroupController {
	private final IChatGroupService chatGroupService;

	/**
	 * 新增单条群-机器人绑定信息
	 * @param chatGroupDTO 群-机器人绑定信息DTO
	 * @return 是否成功
	 */
	@PostMapping("/group/addOne")
	@ApiOperation("新增单条群-机器人绑定信息")
	@ApiOperationSupport(order = 10)
	public R<Boolean> addOne(@RequestBody ChatGroupDTO chatGroupDTO){
		return R.data(chatGroupService.addOne(chatGroupDTO));
	}

	/**
	 * 修改群名的通知
	 * @param chatGroupDTO 修改群名DTO
	 * @return 是否成功
	 */
	@PostMapping("/group/roomTopic")
	@ApiOperation("修改群名的通知")
	@ApiOperationSupport(order = 50)
	public R<Boolean> updateGroupNameTopic(@RequestBody ChatGroupDTO chatGroupDTO){
		return R.data(chatGroupService.updateGroupNameTopic(chatGroupDTO));
	}

	/**
	 * 机器人入群事件通知
	 * @param chatGroupDTO 入群事件参数
	 * @return 是否成功
	 */
	@PostMapping("/group/roomJoin")
	@ApiOperation("入群的事件通知")
	@ApiOperationSupport(order = 51)
	public R<Boolean> roomJoin (@RequestBody ChatGroupDTO chatGroupDTO){
		return R.data(chatGroupService.roomJoin(chatGroupDTO));
	}

	/**
	 * 机器人离群事件通知
	 * @param chatGroupDTO 离群事件参数
	 * @return 是否成功
	 */
	@PostMapping("/group/roomLeave")
	@ApiOperation("离群的事件通知")
	@ApiOperationSupport(order = 52)
	public R<Boolean> roomLeave (@RequestBody ChatGroupDTO chatGroupDTO){
		return R.data(chatGroupService.roomLeave(chatGroupDTO));
	}

	@PostMapping("/group/heartbeat")
	@ApiOperation("心跳包(15秒/次)")
	@ApiOperationSupport(order = 53)
	public R<Boolean> heartbeat(@RequestBody ChatGroupDTO chatGroupDTO){
		return R.data(chatGroupService.heartbeat(chatGroupDTO));
	}


	@GetMapping("/get/service/telephone")
	@ApiOperation("获取服务电话")
	@ApiOperationSupport(order = 54)
	public R<String> getServiceTelephone(@ApiParam(value = "群组ID", required = true) @RequestParam String groupId){
		return R.data(chatGroupService.getServiceTelephone(groupId));
	}




}
